var MyQueue = function() {
  this.stack1 = []
  this.stack2 = []
};

MyQueue.prototype.push = function(x) {
  this.stack1.push(x)
};
MyQueue.prototype.pop = function() {
  if (this.stack2.length === 0) {
    while (this.stack1.length) {
      this.stack2.push(this.stack1.pop())
    }
  }
  return this.stack2.pop()
};
MyQueue.prototype.peek = function() {
  // if (this.stack2.length === 0) {
  //   while (this.stack1.length) {
  //     this.stack2.push(this.stack1.pop())
  //   }
  // }
  const top = this.pop()
  this.stack2.push(top)
  return top
};
MyQueue.prototype.empty = function() {
  return !this.stack1.length && !this.stack2.length
};




const myQueue = new MyQueue();




// function Foo() {
//   // let obj = {}   //1
//   // Foo.call(obj)  // 2
//   // obj.__proto__ = Foo.prototype  // 4
//   // return obj


//   this.a = 1  // 3

  
// }

// let f = new Foo();
// f.xx()